package htmlUnit;

import java.io.IOException;
import java.net.MalformedURLException;

import org.apache.http.client.params.CookiePolicy;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class HTMLUnitUtil {

	/**
	 * @param args
	 */
	
	public void http() {
		HtmlPage spiderPage = null;
		WebClient webClient = null;
		webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
		System.setProperty("apache.commons.httpclient.cookiespec",
				CookiePolicy.BROWSER_COMPATIBILITY);
		webClient.setJavaScriptEnabled(false);
		try {
		spiderPage = webClient.getPage(site);
		spiderPage = webClient.getPage(site);
		bodyString = spiderPage.getBody().asXml();		
		} catch (FailingHttpStatusCodeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	String bodyString = null;
	public String getBodyString() {
		return bodyString;
	}
	String site = null;
	public void setSite(String site) {
		this.site = site;
	}
}
